cmake_minimum_required(VERSION 3.31)
project(mei_file)

set(CMAKE_CXX_STANDARD 26)

set(SOURCES
        mei_file.cpp
        Socket.cpp
        xxhash.cpp
)

# 生成dll动态链接库
add_library(mei_file_dll SHARED ${SOURCES})
target_compile_definitions(mei_file_dll PRIVATE EXPORT_API=1)
target_compile_options(mei_file_dll PRIVATE -static -static-libgcc -static-libstdc++)
target_link_options(mei_file_dll PRIVATE -static -static-libgcc -static-libstdc++)
target_link_libraries(mei_file_dll ws2_32.lib)
set_target_properties(mei_file_dll PROPERTIES OUTPUT_NAME "_mei_file")

# 生成可执行程序
add_executable(mei_file main.cpp ${SOURCES})
target_compile_options(mei_file PRIVATE -static -static-libgcc -static-libstdc++)
target_link_options(mei_file PRIVATE -static -static-libgcc -static-libstdc++)
target_link_libraries(mei_file ws2_32.lib)

# 测试程序
add_executable(mei_file_test test.cpp)
target_compile_definitions(mei_file_test PRIVATE IMPORT_API=1)
target_link_libraries(mei_file_test mei_file_dll)